﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 4.2
// Code is generated on: 
// Code is generated using templates: SD.TemplateBindings.SharedTemplates
// Templates vendor: Solutions Design.
//////////////////////////////////////////////////////////////
using System;
using System.Linq;
using System.Collections.Generic;
using SD.LLBLGen.Pro.LinqSupportClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

using VNet.VisiSuite.VisiBoard.Dal;
using VNet.VisiSuite.VisiBoard.Dal.EntityClasses;
using VNet.VisiSuite.VisiBoard.Dal.FactoryClasses;
using VNet.VisiSuite.VisiBoard.Dal.HelperClasses;
using VNet.VisiSuite.VisiBoard.Dal.RelationClasses;

namespace VNet.VisiSuite.VisiBoard.Dal.Linq
{
	/// <summary>Meta-data class for the construction of Linq queries which are to be executed using LLBLGen Pro code.</summary>
	public partial class LinqMetaData: ILinqMetaData
	{
		#region Class Member Declarations
		private IDataAccessAdapter _adapterToUse;
		private FunctionMappingStore _customFunctionMappings;
		private Context _contextToUse;
		#endregion
		
		/// <summary>CTor. Using this ctor will leave the IDataAccessAdapter object to use empty. To be able to execute the query, an IDataAccessAdapter instance
		/// is required, and has to be set on the LLBLGenProProvider2 object in the query to execute. </summary>
		public LinqMetaData() : this(null, null)
		{
		}
		
		/// <summary>CTor which accepts an IDataAccessAdapter implementing object, which will be used to execute queries created with this metadata class.</summary>
		/// <param name="adapterToUse">the IDataAccessAdapter to use in queries created with this meta data</param>
		/// <remarks> Be aware that the IDataAccessAdapter object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public LinqMetaData(IDataAccessAdapter adapterToUse) : this (adapterToUse, null)
		{
		}

		/// <summary>CTor which accepts an IDataAccessAdapter implementing object, which will be used to execute queries created with this metadata class.</summary>
		/// <param name="adapterToUse">the IDataAccessAdapter to use in queries created with this meta data</param>
		/// <param name="customFunctionMappings">The custom function mappings to use. These take higher precedence than the ones in the DQE to use.</param>
		/// <remarks> Be aware that the IDataAccessAdapter object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public LinqMetaData(IDataAccessAdapter adapterToUse, FunctionMappingStore customFunctionMappings)
		{
			_adapterToUse = adapterToUse;
			_customFunctionMappings = customFunctionMappings;
		}
	
		/// <summary>returns the datasource to use in a Linq query for the entity type specified</summary>
		/// <param name="typeOfEntity">the type of the entity to get the datasource for</param>
		/// <returns>the requested datasource</returns>
		public IDataSource GetQueryableForEntity(int typeOfEntity)
		{
			IDataSource toReturn = null;
			switch((VNet.VisiSuite.VisiBoard.Dal.EntityType)typeOfEntity)
			{
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.AlarmSettingEntity:
					toReturn = this.AlarmSetting;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.AreaEntity:
					toReturn = this.Area;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.AreaShiftEntity:
					toReturn = this.AreaShift;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.BraiderProductEntity:
					toReturn = this.BraiderProduct;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.CellEntity:
					toReturn = this.Cell;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.CellAlarmSettingEntity:
					toReturn = this.CellAlarmSetting;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.CellShiftEntity:
					toReturn = this.CellShift;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.CellStatusEntity:
					toReturn = this.CellStatus;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.DatabaseVersionEntity:
					toReturn = this.DatabaseVersion;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.FractionalInchEntity:
					toReturn = this.FractionalInch;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.HoseSpecEntity:
					toReturn = this.HoseSpec;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.LaunchApplicationEntity:
					toReturn = this.LaunchApplication;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.OperationEntity:
					toReturn = this.Operation;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.OperatorEntity:
					toReturn = this.Operator;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.OperatorAuthEntity:
					toReturn = this.OperatorAuth;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.PlantEntity:
					toReturn = this.Plant;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.ProductEntity:
					toReturn = this.Product;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.ProductionHistoryEntity:
					toReturn = this.ProductionHistory;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.ProductionHistoryDowntimeEventEntity:
					toReturn = this.ProductionHistoryDowntimeEvent;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.ProductionHistoryUndoBufferEntity:
					toReturn = this.ProductionHistoryUndoBuffer;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.ProductionPlanEntity:
					toReturn = this.ProductionPlan;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.ProductOperationTimeEntity:
					toReturn = this.ProductOperationTime;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.ReasonCodeEntity:
					toReturn = this.ReasonCode;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.RollupDefinitionEntity:
					toReturn = this.RollupDefinition;
					break;
				case VNet.VisiSuite.VisiBoard.Dal.EntityType.TableDataChangeEntity:
					toReturn = this.TableDataChange;
					break;
				default:
					toReturn = null;
					break;
			}
			return toReturn;
		}

		/// <summary>returns the datasource to use in a Linq query for the entity type specified</summary>
		/// <typeparam name="TEntity">the type of the entity to get the datasource for</typeparam>
		/// <returns>the requested datasource</returns>
		public DataSource2<TEntity> GetQueryableForEntity<TEntity>()
			    where TEntity : class
		{
    		return new DataSource2<TEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse);
		}

		/// <summary>returns the datasource to use in a Linq query when targeting AlarmSettingEntity instances in the database.</summary>
		public DataSource2<AlarmSettingEntity> AlarmSetting
		{
			get { return new DataSource2<AlarmSettingEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting AreaEntity instances in the database.</summary>
		public DataSource2<AreaEntity> Area
		{
			get { return new DataSource2<AreaEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting AreaShiftEntity instances in the database.</summary>
		public DataSource2<AreaShiftEntity> AreaShift
		{
			get { return new DataSource2<AreaShiftEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting BraiderProductEntity instances in the database.</summary>
		public DataSource2<BraiderProductEntity> BraiderProduct
		{
			get { return new DataSource2<BraiderProductEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting CellEntity instances in the database.</summary>
		public DataSource2<CellEntity> Cell
		{
			get { return new DataSource2<CellEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting CellAlarmSettingEntity instances in the database.</summary>
		public DataSource2<CellAlarmSettingEntity> CellAlarmSetting
		{
			get { return new DataSource2<CellAlarmSettingEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting CellShiftEntity instances in the database.</summary>
		public DataSource2<CellShiftEntity> CellShift
		{
			get { return new DataSource2<CellShiftEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting CellStatusEntity instances in the database.</summary>
		public DataSource2<CellStatusEntity> CellStatus
		{
			get { return new DataSource2<CellStatusEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting DatabaseVersionEntity instances in the database.</summary>
		public DataSource2<DatabaseVersionEntity> DatabaseVersion
		{
			get { return new DataSource2<DatabaseVersionEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting FractionalInchEntity instances in the database.</summary>
		public DataSource2<FractionalInchEntity> FractionalInch
		{
			get { return new DataSource2<FractionalInchEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting HoseSpecEntity instances in the database.</summary>
		public DataSource2<HoseSpecEntity> HoseSpec
		{
			get { return new DataSource2<HoseSpecEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting LaunchApplicationEntity instances in the database.</summary>
		public DataSource2<LaunchApplicationEntity> LaunchApplication
		{
			get { return new DataSource2<LaunchApplicationEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting OperationEntity instances in the database.</summary>
		public DataSource2<OperationEntity> Operation
		{
			get { return new DataSource2<OperationEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting OperatorEntity instances in the database.</summary>
		public DataSource2<OperatorEntity> Operator
		{
			get { return new DataSource2<OperatorEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting OperatorAuthEntity instances in the database.</summary>
		public DataSource2<OperatorAuthEntity> OperatorAuth
		{
			get { return new DataSource2<OperatorAuthEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting PlantEntity instances in the database.</summary>
		public DataSource2<PlantEntity> Plant
		{
			get { return new DataSource2<PlantEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ProductEntity instances in the database.</summary>
		public DataSource2<ProductEntity> Product
		{
			get { return new DataSource2<ProductEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ProductionHistoryEntity instances in the database.</summary>
		public DataSource2<ProductionHistoryEntity> ProductionHistory
		{
			get { return new DataSource2<ProductionHistoryEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ProductionHistoryDowntimeEventEntity instances in the database.</summary>
		public DataSource2<ProductionHistoryDowntimeEventEntity> ProductionHistoryDowntimeEvent
		{
			get { return new DataSource2<ProductionHistoryDowntimeEventEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ProductionHistoryUndoBufferEntity instances in the database.</summary>
		public DataSource2<ProductionHistoryUndoBufferEntity> ProductionHistoryUndoBuffer
		{
			get { return new DataSource2<ProductionHistoryUndoBufferEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ProductionPlanEntity instances in the database.</summary>
		public DataSource2<ProductionPlanEntity> ProductionPlan
		{
			get { return new DataSource2<ProductionPlanEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ProductOperationTimeEntity instances in the database.</summary>
		public DataSource2<ProductOperationTimeEntity> ProductOperationTime
		{
			get { return new DataSource2<ProductOperationTimeEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting ReasonCodeEntity instances in the database.</summary>
		public DataSource2<ReasonCodeEntity> ReasonCode
		{
			get { return new DataSource2<ReasonCodeEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting RollupDefinitionEntity instances in the database.</summary>
		public DataSource2<RollupDefinitionEntity> RollupDefinition
		{
			get { return new DataSource2<RollupDefinitionEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		/// <summary>returns the datasource to use in a Linq query when targeting TableDataChangeEntity instances in the database.</summary>
		public DataSource2<TableDataChangeEntity> TableDataChange
		{
			get { return new DataSource2<TableDataChangeEntity>(_adapterToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
 
		#region Class Property Declarations
		/// <summary> Gets / sets the IDataAccessAdapter to use for the queries created with this meta data object.</summary>
		/// <remarks> Be aware that the IDataAccessAdapter object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public IDataAccessAdapter AdapterToUse
		{
			get { return _adapterToUse;}
			set { _adapterToUse = value;}
		}

		/// <summary>Gets or sets the custom function mappings to use. These take higher precedence than the ones in the DQE to use</summary>
		public FunctionMappingStore CustomFunctionMappings
		{
			get { return _customFunctionMappings; }
			set { _customFunctionMappings = value; }
		}
		
		/// <summary>Gets or sets the Context instance to use for entity fetches.</summary>
		public Context ContextToUse
		{
			get { return _contextToUse;}
			set { _contextToUse = value;}
		}
		#endregion
	}
}